package com.shqcjd.sinopecdemomobile.ui.adapter;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.sinopecdemomobile.R;
import com.shqcjd.sinopecdemomobile.model.pojo.ProblemFeedbackListBean;
import com.shqcjd.sinopecdemomobile.util.UIUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by sy on 2019/5/13.
 */

public class AllProblemAdapter extends BaseQuickAdapter<ProblemFeedbackListBean.ListBean,AllProblemAdapter.ViewHolder> {

    public AllProblemAdapter() {
        super(R.layout.item_all_problem);
    }

    @Override
    protected void convert(AllProblemAdapter.ViewHolder helper, ProblemFeedbackListBean.ListBean item) {
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.ic_default_small)	//加载成功之前占位图
                .error(R.mipmap.ic_default_small);	//加载错误之后的错误图
//                .override(87,87);//指定图片的缩放类型为centerCrop （等比例缩放图片，直到图片的宽高都
        Glide.with(mContext)
                .load(item.url)
                .apply(options)
                .into(helper.iv_img);

        helper.tv_name.setText(""+item.projectName);
        helper.tv_info.setText(""+item.problemDescription);
        helper.tv_type.setText(""+item.problemType);
        helper.tv_time.setText(""+item.startTime);
        helper.tv_manager_name.setText(""+item.managerName);
        helper.tv_manager_time.setText(UIUtils.isNull(item.managerReplyTime));

        ProblemUserAdapter problemUserAdapter = new ProblemUserAdapter();
        helper.rv_user_list.setLayoutManager(new LinearLayoutManager(mContext));
        helper.rv_user_list.setAdapter(problemUserAdapter);
        problemUserAdapter.setNewData(item.expertList);



    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.iv_img)
        ImageView iv_img;
        @BindView(R.id.rv_user_list)
        RecyclerView rv_user_list;
        @BindView(R.id.tv_manager_name)
        TextView tv_manager_name;
        @BindView(R.id.tv_manager_time)
        TextView tv_manager_time;
        @BindView(R.id.tv_name)
        TextView tv_name;
        @BindView(R.id.tv_info)
        TextView tv_info;
        @BindView(R.id.tv_type)
        TextView tv_type;
        @BindView(R.id.tv_time)
        TextView tv_time;
        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

}
